import { getUnitListApi } from '@/service/api/businessApi';
export function unitHooks() {
  const getUnitList = async () => {
    const res = await getUnitListApi({ pageNo: 1, pageSize: 1000 });
    if (res?.data?.data) return res.data.data;
    return [];
  };

  const getUnitNameById = (data: any, id: any) => {
    return data.find((item: any) => item.id === id)?.name;
  };

  return {
    getUnitList,
    getUnitNameById
  };
}
